package com.taosdata.jdbc.springbootdemo.domain.thread;

import com.taosdata.jdbc.springbootdemo.config.beanContext.BeanContext;
import com.taosdata.jdbc.springbootdemo.domain.stables.SuperTable;
import com.taosdata.jdbc.springbootdemo.mapper.tdengine.stableMapper.StableMapper;
import com.taosdata.jdbc.springbootdemo.service.tdengine.StableService;
import com.taosdata.jdbc.springbootdemo.serviceImpl.tdengine.StableServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author zhmsky
 * @date 2022/9/26 15:51
 */
@Slf4j
public class InsertThread implements Runnable {

    private CopyOnWriteArrayList<SuperTable> superTableList;

    private StableService stableService;

    public InsertThread(CopyOnWriteArrayList<SuperTable> superTableList) {
        this.superTableList = superTableList;
    }

    @Override
    public void run() {
//        StableMapper mapper = BeanContext.getApplicationContext().getBean(StableService.class);
        stableService = BeanContext.getApplicationContext().getBean(StableService.class);
        stableService.insertCommonData(superTableList);
        log.info(Thread.currentThread().getName() + ":" + superTableList.toString());
    }

}